#include <string.h>

/*
 * memset - Fill a region of memory with the given value
 * 
 */
 
void *memset(void *addr, int byte, uint_32 count)
{
	char *xaddr = addr;

	while(count--)
		*xaddr++ = byte;
		
	return addr;
}

/*
 * memcpy - Copia un area de memoria a otra
 * 
 */
 
void *memcpy(void *dest, const void *src, uint_32 count)
{
	char *tmp = dest;
	const char *s = src;

	while (count--)
		*tmp++ = *s++;
	return dest;
}

/*
 * strcpy - Copia un string null-terminated
 * 
 */
 
char *strcpy(char *dest, const char *src)
{
	char *tmp = dest;

	while ((*dest++ = *src++) != '\0')
		/* nothing */;
	return tmp;
}

/*
 * strcpy - Copia un string null-terminated con un limite maximo
 * 
 */

char *strncpy(char *dest, const char *src, uint_32 count)
{
	char *tmp = dest;

	while (count) {
		if ((*tmp = *src) != 0)
			src++;
		tmp++;
		count--;
	}
	return dest;
}

/*
 * strlen - Devuelve la longitud del string
 *
 */
uint_32 strlen(const char *s)
{
	const char *sc;

	for (sc = s; *sc != '\0'; ++sc)
		/* nothing */;
	return sc - s;
}
